using HttpContextBodyToStreamContentDemo.Api.Middlewares;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHttpClient<ProxyHttpClient>()
    .ConfigurePrimaryHttpMessageHandler(x => new HttpClientHandler()
    {
        AllowAutoRedirect = false,
        MaxConnectionsPerServer = int.MaxValue,
        UseCookies = false,
    });
builder.Services.AddSingleton<IUrlRewriter>(new PrefixRewriter("/order", "https://localhost:7132"));

var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthorization();
app.UseMiddleware<ProxyMiddleware>();
app.MapControllers();
app.Run();